#include<bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
struct CAR{
    int d;
    int v0;
    int a;
    int d1;//out of speed (left)
    int d2;
}c[100005];
double tmp;
int dl;

int p[100005];

int t[1000005];

int ans=0;

int Linf[3005];
int Inf[3005][3005];

bool vis[100005];
bool flag;
int ans2;

int ub(double Number){
    int Numint=int(Number);
    if(Number-double(Numint)>0) return Numint+1;
    return Numint;
}

int lowbit(int x){
    return x&(-x);
}

void mo(int pos){
    while(pos<=L){
        t[pos]++;
        pos+=lowbit(pos);
    }
}

int sum(int pos){
    int Ans=0;
    while(pos>0){
        Ans+=t[pos];
        pos-=lowbit(pos);
    }
    return Ans;
}

void dfs(int pos,int ml){
    if(flag==1) return;
    if(pos>m||ml==0){
        int cunt=0;
        for(int i=1;i<=n;i++){
            if(vis[i]==1) cunt++;
        }
        if(cunt==ans) flag=1;
        return;
    }
    dfs(pos+1,ml);
    bool vis2[100005];
    for(int i=1;i<=Linf[pos];i++){
        if(vis[Inf[pos][i]]){
            vis2[Inf[pos][i]]=1;
        }
        vis[Inf[pos][i]]=1;
    }
    dfs(pos+1,ml-1);
    for(int i=1;i<=Linf[pos];i++){
        if(!vis2[Inf[pos][i]]){
            vis[Inf[pos][i]]=0;
        }
    }
    return;
}

bool check(int m1){
    for(int i=1;i<=n;i++){
        vis[i]=0;
    }
    flag=0;
    dfs(1,m1);
    return flag;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int Data=1;Data<=T;Data++){
        cin>>n>>m>>L>>V;
        L++;
        for(int i=0;i<=1000000;i++){
            t[i]=0;
        }
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v0>>c[i].a;
            c[i].d++;
            if(c[i].v0<=V&&c[i].a<=0){
                i--;
                n--;
                continue;
            }
            //if(c[i].v0<=V&&sqrt(double(c[i].v0*c[i].v0+2*c[i].a*(L-c[i].d)))<=double(V)){
            //
            //}
            if(c[i].a>0&&c[i].v0<=V){
                tmp=double(V*V-c[i].v0*c[i].v0)/2.0/double(c[i].a);
                //cout<<tmp<<endl;
                dl=int(tmp)+1;
                if(dl+c[i].d>L){
                    i--;
                    n--;
                    continue;
                }
                c[i].d1=dl+c[i].d;
                c[i].d2=L;
            }
            if(c[i].v0>V&&c[i].a>=0){
                c[i].d1=c[i].d;
                c[i].d2=L;
            }
            if(c[i].v0>V&&c[i].a<0){
                tmp=double(V*V-c[i].v0*c[i].v0)/2.0/double(c[i].a);
                //cout<<tmp<<endl;
                dl=ub(tmp)-1;
                c[i].d1=c[i].d;
                c[i].d2=min(L,c[i].d+dl);
            }
            //cout<<c[i].d<<" "<<c[i].v0<<" "<<c[i].a<<" "<<c[i].d1<<"->"<<c[i].d2<<endl;
        }

        for(int i=1;i<=m;i++){
            cin>>p[i];
            mo(p[i]);
        }

        for(int i=1;i<=n;i++){
            if(sum(c[i].d2)-sum(c[i].d1-1)>0){
                ans++;
            }
        }

        cout<<ans<<" ";

        if(ans==0){
            cout<<m<<endl;
            continue;
        }

        ans2=1;

        for(int i=1;i<=m;i++){
            Linf[i]=0;
            for(int j=1;j<=n;j++){
                if(c[j].d1<=p[i]&&p[i]<=c[j].d2){
                    Linf[i]++;
                    Inf[i][Linf[i]]=j;
                }
            }
        }

//        for(int j=1;j<=m;j++){
//            for(int i=1;i<=Linf[j];i++){
//                cout<<Inf[j][i]<<" ";
//            }
//            cout<<endl;
//        }


        while(check(ans2)==0){
            //cout<<ans<<endl;
            ans2++;
        }

        cout<<m-ans2<<endl;
    }
    return 0;
}
